package com.higgins.eventtracking.server.dataModel;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.higgins.eventtracking.client.dto.TrackingEventDTO;

@PersistenceCapable
public class TrackingEvent {
	@SuppressWarnings("unused")
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String eventType;
	@Persistent
	private Date timestamp;
	@Persistent
	private Double distance;
	@Persistent
	private Integer minutes;
	@Persistent
	private Integer seconds;
	@Persistent
	private Double weight;
	@Persistent
	private Integer reps;
	@Persistent
	private Integer points;
	
	
	public Key getKey()	{
		return key;
	}
	public TrackingEvent()	{
		
	}
	public String toString()	{
		String returnString = eventType;
		if (distance>0.0)	
			returnString = returnString + " " + distance.toString() + " Km;";
		if ((minutes > 0.0) || (seconds > 0.0))
			returnString = returnString + " " + minutes.toString() + ":" + seconds.toString() + ";";
		if (weight > 0.0)
			returnString = returnString + " " + weight.toString() + " Kg;";
		if (reps > 0)
			returnString = returnString + " x" + reps.toString() + ";";
		return returnString;
	}
	public TrackingEvent(String eventType, Date timestamp, Double distance, Integer minutes, Integer seconds, Double weight, Integer reps)	{
		this.eventType = eventType;
		this.timestamp = timestamp;
		this.distance = distance;
		this.minutes = minutes;
		this.seconds = seconds;
		this.weight = weight;
		this.reps = reps;
	}
	public TrackingEvent(TrackingEventDTO dto)	{
		this.eventType = dto.getEventType();
		this.timestamp = dto.getTimeStamp();
		this.distance = dto.getDistance();
		this.minutes = dto.getMinutes();
		this.seconds = dto.getSeconds();
		this.weight = dto.getWeight();
		this.reps = dto.getReps();
	}
	public TrackingEventDTO getDTO()	{
		TrackingEventDTO dto = new TrackingEventDTO(eventType, timestamp, distance, minutes, seconds, weight, reps);
		return dto;
	}
	public void setDTO(TrackingEventDTO dto)	{
		this.eventType = dto.getEventType();
		this.timestamp = dto.getTimeStamp();
		this.distance = dto.getDistance();
		this.minutes = dto.getMinutes();
		this.seconds = dto.getSeconds();
		this.weight = dto.getWeight();
		this.reps = dto.getReps();
	}
	
	public void setEventType(String eventType)	{
		this.eventType = eventType;
	}
	public String getEventType()	{
		return eventType;
	}
	public void setTimeStamp(Date timestamp)	{
		this.timestamp = timestamp;
	}
	public Date getTimeStamp()	{
		return timestamp;
	}
	public void setDistance(Double distance)	{
		this.distance = distance;
	}
	public Double getDistance()	{
		return distance;
	}
	public void setMinutes(Integer minutes)	{
		this.minutes = minutes;
	}
	public Integer getMinutes()	{
		return minutes;
	}
	public void setSeconds(Integer seconds)		{
		this.seconds = seconds;
	}
	public Integer getSeconds()	{
		return seconds;
	}
	public void setWeight(Double weight)	{
		this.weight = weight;
	}
	public Double getWeight()	{
		return weight;
	}
	public void setReps(Integer reps)	{
		this.reps = reps;
	}
	public Integer getReps()	{
		return reps;
	}
	public void setPoints(Integer points)	{
		this.points = points;
	}
	public Integer getPoints()	{
		return points;
	}

}
